home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / AIncludes / OSUtils.a < prev    next >
Encoding:
Text File  |  1998-02-12  |  12.2 KB  |  499 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        OSUtils.a
  3. ;
  4. ;    Contains:    OS Utilities Interfaces.
  5. ;
  6. ;    Version:    Technology:    Mac OS 8
  7. ;                Release:    Universal Interfaces 3.1
  8. ;
  9. ;    Copyright:    © 1985-1998 by Apple Computer, Inc., all rights reserved
  10. ;
  11. ;    Bugs?:        Please include the the file and version information (from above) with
  12. ;                the problem description.  Developers belonging to one of the Apple
  13. ;                developer programs can submit bug reports to:
  14. ;
  15. ;                    devsupport@apple.com
  16. ;
  17. ;
  18.     IF &TYPE('__OSUTILS__') = 'UNDEFINED' THEN
  19. __OSUTILS__ SET 1
  20.  
  21.     IF &TYPE('__MACTYPES__') = 'UNDEFINED' THEN
  22.     include 'MacTypes.a'
  23.     ENDIF
  24.     IF &TYPE('__MIXEDMODE__') = 'UNDEFINED' THEN
  25.     include 'MixedMode.a'
  26.     ENDIF
  27. ;   HandToHand and other memory utilties were moved to MacMemory.h 
  28.     IF &TYPE('__MACMEMORY__') = 'UNDEFINED' THEN
  29.     include 'MacMemory.a'
  30.     ENDIF
  31. ;   GetTrapAddress and other trap table utilties were moved to Patches.h 
  32.     IF &TYPE('__PATCHES__') = 'UNDEFINED' THEN
  33.     include 'Patches.a'
  34.     ENDIF
  35. ;   Date and Time utilties were moved to DateTimeUtils.h 
  36.     IF &TYPE('__DATETIMEUTILS__') = 'UNDEFINED' THEN
  37.     include 'DateTimeUtils.a'
  38.     ENDIF
  39.     IF ¬ TARGET_OS_MAC THEN
  40.     IF &TYPE('__ENDIAN__') = 'UNDEFINED' THEN
  41.     include 'Endian.a'
  42.     ENDIF
  43.     ENDIF
  44.  
  45. useFree                            EQU        0
  46. useATalk                        EQU        1
  47. useAsync                        EQU        2
  48. useExtClk                        EQU        3                    ;Externally clocked
  49. useMIDI                            EQU        4
  50.  
  51. false32b                        EQU        0                    ;24 bit addressing error
  52. true32b                            EQU        1                    ;32 bit addressing error
  53.  
  54.                                                             ; result types for RelString Call 
  55. sortsBefore                        EQU        -1                    ;first string < second string
  56. sortsEqual                        EQU        0                    ;first string = second string
  57. sortsAfter                        EQU        1                    ;first string > second string
  58.  
  59. dummyType                        EQU        0
  60. vType                            EQU        1
  61. ioQType                            EQU        2
  62. drvQType                        EQU        3
  63. evType                            EQU        4
  64. fsQType                            EQU        5
  65. sIQType                            EQU        6
  66. dtQType                            EQU        7
  67. nmType                            EQU        8
  68. ; typedef SignedByte                     QTypes
  69.  
  70. SysParmType                RECORD 0
  71. valid                     ds.b    1                ; offset: $0 (0)
  72. aTalkA                     ds.b    1                ; offset: $1 (1)
  73. aTalkB                     ds.b    1                ; offset: $2 (2)
  74. config                     ds.b    1                ; offset: $3 (3)
  75. portA                     ds.w    1                ; offset: $4 (4)
  76. portB                     ds.w    1                ; offset: $6 (6)
  77. alarm                     ds.l    1                ; offset: $8 (8)
  78. font                     ds.w    1                ; offset: $C (12)
  79. kbdPrint                 ds.w    1                ; offset: $E (14)
  80. volClik                     ds.w    1                ; offset: $10 (16)
  81. misc                     ds.w    1                ; offset: $12 (18)
  82. sizeof                     EQU *                    ; size:   $14 (20)
  83.                         ENDR
  84. ; typedef struct SysParmType *            SysPPtr
  85.  
  86. QElem                    RECORD 0
  87. qLink                     ds.l    1                ; offset: $0 (0)
  88. qType                     ds.w    1                ; offset: $4 (4)
  89. qData                     ds.w    1                ; offset: $6 (6) <-- really an array of length one
  90. sizeof                     EQU *                    ; size:   $8 (8)
  91.                         ENDR
  92. ; typedef struct QElem *                QElemPtr
  93.  
  94.     IF TARGET_OS_MAC THEN
  95. QHdr                    RECORD 0
  96. qFlags                     ds.w    1                ; offset: $0 (0)
  97. qHead                     ds.l    1                ; offset: $2 (2)
  98. qTail                     ds.l    1                ; offset: $6 (6)
  99. sizeof                     EQU *                    ; size:   $A (10)
  100.                         ENDR
  101. ; typedef struct QHdr *                    QHdrPtr
  102.  
  103.     ELSE
  104.  
  105. ;   QuickTime 3.0:
  106. ;   this version of QHdr contains the Mutex necessary for
  107. ;   non-mac non-interrupt code
  108.  
  109.  
  110. QHdr                    RECORD 0
  111. qFlags                     ds.w    1                ; offset: $0 (0)
  112. pad                         ds.w    1                ; offset: $2 (2)
  113. MutexID                     ds.l    1                ; offset: $4 (4)
  114. qHead                     ds.l    1                ; offset: $8 (8)
  115. qTail                     ds.l    1                ; offset: $C (12)
  116. sizeof                     EQU *                    ; size:   $10 (16)
  117.                         ENDR
  118. ; typedef struct QHdr *                    QHdrPtr
  119.  
  120.     ENDIF    ; TARGET_OS_MAC
  121.  
  122.  
  123. DeferredTask            RECORD 0
  124. qLink                     ds.l    1                ; offset: $0 (0)
  125. qType                     ds.w    1                ; offset: $4 (4)
  126. dtFlags                     ds.w    1                ; offset: $6 (6)
  127. dtAddr                     ds.l    1                ; offset: $8 (8)
  128. dtParam                     ds.l    1                ; offset: $C (12)
  129. dtReserved                 ds.l    1                ; offset: $10 (16)
  130. sizeof                     EQU *                    ; size:   $14 (20)
  131.                         ENDR
  132. ; typedef struct DeferredTask *            DeferredTaskPtr
  133.  
  134.     IF TARGET_OS_MAC THEN
  135. MachineLocation            RECORD 0
  136. latitude                 ds.l    1                ; offset: $0 (0)
  137. longitude                 ds.l    1                ; offset: $4 (4)
  138. dlsDelta                 ds.b    1                ; offset: $8 (8)        ;  signed byte; daylight savings delta 
  139.                          ORG 8
  140. gmtDelta                 ds.l    1                ; offset: $8 (8)        ;  use low 24-bits only 
  141. sizeof                     EQU *                    ; size:   $C (12)
  142.                         ENDR
  143.     ELSE
  144. ;    QuickTime 3.0:
  145. ;    Alignment of MachineLocation is weird. The union above used for delta
  146. ;    tends not to work on non-Mac compilers.
  147. ;
  148.  
  149. MachineLocation            RECORD 0
  150. latitude                 ds.l    1                ; offset: $0 (0)
  151. longitude                 ds.l    1                ; offset: $4 (4)
  152. delta                     ds        BigEndianLong    ; offset: $8 (8)        ;  high byte is daylight savings delta, low 24-bits is GMT delta 
  153. sizeof                     EQU *                    ; size:   $C (12)
  154.                         ENDR
  155.     ENDIF    ; TARGET_OS_MAC
  156. ;
  157. ; pascal Boolean IsMetric(void )
  158. ;
  159.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  160.         Macro
  161.         _IsMetric
  162.             move.w              #$0004,-(sp)
  163.             dc.w                $A9ED
  164.         EndM
  165.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  166.         IMPORT_CFM_FUNCTION IsMetric
  167.     ENDIF
  168.  
  169. ;
  170. ; pascal SysPPtr GetSysPPtr(void )
  171. ;
  172.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  173.         Macro
  174.         _GetSysPPtr           &dest=(sp)
  175.             move.l            #$000001F8,&dest
  176.         EndM
  177.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  178.         IMPORT_CFM_FUNCTION GetSysPPtr
  179.     ENDIF
  180.  
  181.  
  182. ;    NOTE: SysBeep() has been moved to Sound.h.  
  183. ;          We could not automatically #include Sound.h in this file
  184. ;          because Sound.h indirectly #include's OSUtils.h which
  185. ;          would make a circular include.
  186. ;
  187.  
  188. ;
  189. ; pascal OSErr DTInstall(DeferredTaskPtr dtTaskPtr)
  190. ;
  191.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  192.         ; parameters:
  193.         ;    dtTaskPtr       => A0
  194.         ; returns:
  195.         ;    OSErr           <= D0
  196.         _DTInstall:    OPWORD    $A082
  197.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  198.         IMPORT_CFM_FUNCTION DTInstall
  199.     ENDIF
  200.  
  201.  
  202.  
  203. ;
  204. ; pascal SInt8 GetMMUMode(void)
  205. ;
  206.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  207.         Macro
  208.         _GetMMUMode           &dest=(sp)
  209.             move.b            $0CB2,&dest
  210.         EndM
  211.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  212.         IMPORT_CFM_FUNCTION GetMMUMode
  213.     ENDIF
  214.  
  215. ;
  216. ; pascal SInt8 SwapMMUMode(SInt8 mode)
  217. ;
  218.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  219.         ; parameters:
  220.         ;    mode            => D0
  221.         ; returns:
  222.         ;    SInt8           <= D0
  223.         _SwapMMUMode:    OPWORD    $A05D
  224.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  225.         IMPORT_CFM_FUNCTION SwapMMUMode
  226.     ENDIF
  227.  
  228. ;
  229. ; pascal void Delay(unsigned long numTicks, unsigned long *finalTicks)
  230. ;
  231.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  232.         _Delay:    OPWORD    $A03B
  233.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  234.         IMPORT_CFM_FUNCTION Delay
  235.     ENDIF
  236.  
  237.  
  238. ;
  239. ; pascal OSErr WriteParam(void )
  240. ;
  241.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  242.         _WriteParam:    OPWORD    $A038
  243.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  244.         IMPORT_CFM_FUNCTION WriteParam
  245.     ENDIF
  246.  
  247. ;
  248. ; pascal void Enqueue(QElemPtr qElement, QHdrPtr qHeader)
  249. ;
  250.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  251.         ; parameters:
  252.         ;    qElement        => A0
  253.         ;    qHeader         => A1
  254.         _Enqueue:    OPWORD    $A96F
  255.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  256.         IMPORT_CFM_FUNCTION Enqueue
  257.     ENDIF
  258.  
  259. ;
  260. ; pascal OSErr Dequeue(QElemPtr qElement, QHdrPtr qHeader)
  261. ;
  262.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  263.         ; parameters:
  264.         ;    qElement        => A0
  265.         ;    qHeader         => A1
  266.         ; returns:
  267.         ;    OSErr           <= D0
  268.         _Dequeue:    OPWORD    $A96E
  269.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  270.         IMPORT_CFM_FUNCTION Dequeue
  271.     ENDIF
  272.  
  273. ;
  274. ; pascal OSErr InitUtil(void )
  275. ;
  276.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  277.         ; returns:
  278.         ;    OSErr           <= D0
  279.         _InitUtil:    OPWORD    $A03F
  280.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  281.         IMPORT_CFM_FUNCTION InitUtil
  282.     ENDIF
  283.  
  284.  
  285.     IF TARGET_CPU_PPC THEN
  286. ;
  287. ; pascal void MakeDataExecutable(void *baseAddress, unsigned long length)
  288. ;
  289.     IF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  290.         IMPORT_CFM_FUNCTION MakeDataExecutable
  291.     ENDIF
  292.  
  293.     ENDIF    ; TARGET_CPU_PPC
  294.     IF TARGET_CPU_68K THEN
  295. ;
  296. ; pascal Boolean SwapInstructionCache(Boolean cacheEnable)
  297. ;
  298.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  299.         Macro
  300.         _SwapInstructionCache
  301.             moveq               #0,D0
  302.             dc.w                $A098
  303.         EndM
  304.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  305.         IMPORT_CFM_FUNCTION SwapInstructionCache
  306.     ENDIF
  307.  
  308. ;
  309. ; pascal void FlushInstructionCache(void )
  310. ;
  311.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  312.         Macro
  313.         _FlushInstructionCache
  314.             moveq               #1,D0
  315.             dc.w                $A098
  316.         EndM
  317.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  318.         IMPORT_CFM_FUNCTION FlushInstructionCache
  319.     ENDIF
  320.  
  321. ;
  322. ; pascal Boolean SwapDataCache(Boolean cacheEnable)
  323. ;
  324.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  325.         Macro
  326.         _SwapDataCache
  327.             moveq               #2,D0
  328.             dc.w                $A098
  329.         EndM
  330.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  331.         IMPORT_CFM_FUNCTION SwapDataCache
  332.     ENDIF
  333.  
  334. ;
  335. ; pascal void FlushDataCache(void )
  336. ;
  337.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  338.         Macro
  339.         _FlushDataCache
  340.             moveq               #3,D0
  341.             dc.w                $A098
  342.         EndM
  343.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  344.         IMPORT_CFM_FUNCTION FlushDataCache
  345.     ENDIF
  346.  
  347. ;
  348. ; pascal void FlushCodeCache(void )
  349. ;
  350.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  351.         _FlushCodeCache:    OPWORD    $A0BD
  352.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  353.         IMPORT_CFM_FUNCTION FlushCodeCache
  354.     ENDIF
  355.  
  356. ;
  357. ; pascal OSErr FlushCodeCacheRange(void *address, unsigned long count)
  358. ;
  359.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  360.         ; parameters:
  361.         ;    address         => A0
  362.         ;    count           => A1
  363.         ; returns:
  364.         ;    OSErr           <= D0
  365.         Macro
  366.         _FlushCodeCacheRange
  367.             moveq               #9,D0
  368.             dc.w                $A098
  369.         EndM
  370.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  371.         IMPORT_CFM_FUNCTION FlushCodeCacheRange
  372.     ENDIF
  373.  
  374. ;
  375. ; pascal void FlushExternalCache(void )
  376. ;
  377.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  378.         Macro
  379.         _FlushExternalCache
  380.             moveq               #6,D0
  381.             dc.w                $A098
  382.         EndM
  383.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  384.         IMPORT_CFM_FUNCTION FlushExternalCache
  385.     ENDIF
  386.  
  387.     ENDIF    ; TARGET_CPU_68K
  388. ;
  389. ; pascal void ReadLocation(MachineLocation *loc)
  390. ;
  391.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  392.         ; parameters:
  393.         ;    loc             => A0
  394.         Macro
  395.         _ReadLocation
  396.             move.l              #$000C00E4,D0
  397.             dc.w                $A051
  398.         EndM
  399.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  400.         IMPORT_CFM_FUNCTION ReadLocation
  401.     ENDIF
  402.  
  403. ;
  404. ; pascal void WriteLocation(const MachineLocation *loc)
  405. ;
  406.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  407.         ; parameters:
  408.         ;    loc             => A0
  409.         Macro
  410.         _WriteLocation
  411.             move.l              #$000C00E4,D0
  412.             dc.w                $A052
  413.         EndM
  414.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  415.         IMPORT_CFM_FUNCTION WriteLocation
  416.     ENDIF
  417.  
  418.  
  419.  
  420.     IF OLDROUTINENAMES THEN
  421.     ENDIF    ; OLDROUTINENAMES
  422. ;    NOTE: SysEnvirons is obsolete.  You should be using Gestalt.
  423. ;
  424.  
  425. ;  Environs Equates 
  426.  
  427. curSysEnvVers                    EQU        2                    ;Updated to equal latest SysEnvirons version
  428. SysEnvRec                RECORD 0
  429. environsVersion             ds.w    1                ; offset: $0 (0)
  430. machineType                 ds.w    1                ; offset: $2 (2)
  431. systemVersion             ds.w    1                ; offset: $4 (4)
  432. processor                 ds.w    1                ; offset: $6 (6)
  433. hasFPU                     ds.b    1                ; offset: $8 (8)
  434. hasColorQD                 ds.b    1                ; offset: $9 (9)
  435. keyBoardType             ds.w    1                ; offset: $A (10)
  436. atDrvrVersNum             ds.w    1                ; offset: $C (12)
  437. sysVRefNum                 ds.w    1                ; offset: $E (14)
  438. sizeof                     EQU *                    ; size:   $10 (16)
  439.                         ENDR
  440.  
  441.                                                             ; Machine Types 
  442. envMac                            EQU        -1
  443. envXL                            EQU        -2
  444. envMachUnknown                    EQU        0
  445. env512KE                        EQU        1
  446. envMacPlus                        EQU        2
  447. envSE                            EQU        3
  448. envMacII                        EQU        4
  449. envMacIIx                        EQU        5
  450. envMacIIcx                        EQU        6
  451. envSE30                            EQU        7
  452. envPortable                        EQU        8
  453. envMacIIci                        EQU        9
  454. envMacIIfx                        EQU        11
  455.  
  456.                                                             ; CPU types 
  457. envCPUUnknown                    EQU        0
  458. env68000                        EQU        1
  459. env68010                        EQU        2
  460. env68020                        EQU        3
  461. env68030                        EQU        4
  462. env68040                        EQU        5
  463.  
  464.                                                             ; Keyboard types 
  465. envUnknownKbd                    EQU        0
  466. envMacKbd                        EQU        1
  467. envMacAndPad                    EQU        2
  468. envMacPlusKbd                    EQU        3
  469. envAExtendKbd                    EQU        4
  470. envStandADBKbd                    EQU        5
  471. envPrtblADBKbd                    EQU        6
  472. envPrtblISOKbd                    EQU        7
  473. envStdISOADBKbd                    EQU        8
  474. envExtISOADBKbd                    EQU        9
  475. ;
  476. ; pascal OSErr SysEnvirons(short versionRequested, SysEnvRec *theWorld)
  477. ;
  478.     IF TARGET_OS_MAC ** TARGET_CPU_68K ** ¬ TARGET_RT_MAC_CFM THEN
  479.         ; parameters:
  480.         ;    versionRequetheWorld=> D0
  481.         ;    theWorld        => A0
  482.         ; returns:
  483.         ;    OSErr           <= D0
  484.         _SysEnvirons:    OPWORD    $A090
  485.     ELSEIF TARGET_OS_MAC ** TARGET_RT_MAC_CFM THEN
  486.         IMPORT_CFM_FUNCTION SysEnvirons
  487.     ENDIF
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.     ENDIF ; __OSUTILS__ 
  495.  
  496.